package com.xspace.android.xafcommon.util;

import java.io.Serializable;

public class CustomDate implements Serializable {

    private static final long serialVersionUID = 1L;

    public int year;
    public int month;
    public int day;
    public int week;

    public CustomDate(int year, int month, int day) {
        if (month > 12) {
            month = 1;
            year++;
        } else if (month < 1) {
            month = 12;
            year--;
        }
        this.year = year;
        this.month = month;
        this.day = day;
        this.week = CalendarUtil.getWeekDay();
    }

    public CustomDate() {
        this.year = CalendarUtil.getYear();
        this.month = CalendarUtil.getMonth();
        this.day = CalendarUtil.getCurrentMonthDay();
        this.week = CalendarUtil.getWeekDayFromDate(year, month);
    }

    public static CustomDate modifyDayForObject(CustomDate date, int day) {
        return new CustomDate(date.year, date.month, day);
    }

    @Override
    public String toString() {
        String mmStr;
        if (month < 10) {
            mmStr = "0" + month;
        } else {
            mmStr = String.valueOf(month);
        }
        String dayStr;
        if (day < 10) {
            dayStr = "0" + day;
        } else {
            dayStr = String.valueOf(day);
        }
        return year + "-" + mmStr + "-" + dayStr;
    }

    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }

    public int getMonth() {
        return month;
    }

    public void setMonth(int month) {
        this.month = month;
    }

    public int getDay() {
        return day;
    }

    public void setDay(int day) {
        this.day = day;
    }

    public int getWeek() {
        return week;
    }

    public void setWeek(int week) {
        this.week = week;
    }

}
